package com.ymttest.database.sqlwapper;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ymatou.query.trading.api.parameter.OrderStatus;
import com.ymt.core.tool.Logger;
import com.ymt.database.SqlManager;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.YMTDateUtil;

/************************************************************************************
 * @File name :TradingQueryDefaultWapper.java
 * @Author : sunsheng
 * @Date : 2015年10月14日
 * @Copyright : 洋码头
 ************************************************************************************/
public class TradingQueryDefaultWapper {
	SqlManager manage;

	public TradingQueryDefaultWapper() {
		manage = new SqlManager("ymt" + EnvSetup.getEnv());
	}

	/**
	 * 根据卖家id查询黑名单
	 * 
	 * @param sellerId
	 *            卖家id
	 * @return List<HashMap>
	 * @throws InterruptedException
	 */
	public List<Map> selectBlacklistBySellerId(int sellerId) throws InterruptedException {
		@SuppressWarnings("unchecked")
		List<Map> list = manage.getSelectResults(
				"com.ymttest.database.mapping.TradingQueryDefaultMapper.selectBlacklistBySellerId", sellerId);
		// manage.close();
		return list;
	}

	/**
	 * 根据卖家id查询order,orderinfo
	 * 
	 * @param Map
	 *            m
	 * @return List<HashMap>
	 * @throws InterruptedException
	 */
	public List<Map> selectOrderAndOrderInfo(Map m) throws InterruptedException {
		@SuppressWarnings("unchecked")
		List<Map> list = manage.getSelectResults(
				"com.ymttest.database.mapping.TradingQueryDefaultMapper.selectOrderAndOrderInfo", m);
		// manage.close();
		return list;
	}

	/**
	 * 根据卖家id查询order,orderinfo,idPic
	 * 
	 * @param Map
	 *            m
	 * @return List<HashMap>
	 * @throws InterruptedException
	 */
	public List<Map> selectOrderAndOrderInfoAndidPic(Map m) throws InterruptedException {
		@SuppressWarnings("unchecked")
		List<Map> list = manage.getSelectResults(
				"com.ymttest.database.mapping.TradingQueryDefaultMapper.selectOrderAndOrderInfoAndidPic", m);
		// manage.close();
		return list;
	}

	/**
	 * 根据userid,productid 查询selectBuyedNumByProductid
	 * 
	 * @param Map
	 *            m
	 * @return List<HashMap>
	 * @throws InterruptedException
	 */
	public List<Map> selectBuyedNumByProductid(Map m) throws InterruptedException {
		@SuppressWarnings("unchecked")
		List<Map> list = manage.getSelectResults(
				"com.ymttest.database.mapping.TradingQueryDefaultMapper.selectBuyedNumByProductid", m);
		// manage.close();
		return list;
	}

	/**
	 * 根据买家id查询order,Ymt_Orders,Ymt_OrderInfo,Ymt_Order_Frozen
	 * 
	 * @param Map
	 *            m
	 * @return List<HashMap>
	 * @throws InterruptedException
	 */
	public List<Map> getBuyerOrderList(Map m) throws InterruptedException {
		@SuppressWarnings("unchecked")
		List<Map> list = manage.getSelectResults(
				"com.ymttest.database.mapping.TradingQueryDefaultMapper.getBuyerOrderList", m);
		return list;
	}

	public static void main(String args[]) {
		HashMap m = new HashMap();
		List<Integer> t = new ArrayList<Integer>();
		// t.add(13);
		t.add(4);
		int orderStatusUsingMethod = OrderStatus.GetOrderStatusUsingMethod(t);
		m.put("userId", "216");
		m.put("tradingStatus", t);
		m.put("paidInFull", 1);
		m.put("bondedArea", 3);
		m.put("catalogStatus", 5);
		m.put("startDate", YMTDateUtil.getBeforeOrNextDay(-365));
		m.put("endDate", YMTDateUtil.getBeforeOrNextDay(1));
		m.put("productId", "aa5ddccf-d911-4440-a4c7-d5d2259e4093");
		m.put("orderStatusUsingMethod", orderStatusUsingMethod);
		// m.put("idStartDate", DateUtils.getBeforeOrNextDay(-90));
		// m.put("idEndDate", DateUtils.getBeforeOrNextDay(1));

		// m.put(key, value)
		// Logger.debug(new DefaultWapper().selectCouponCode(1113, 23892));
		// List<Map> list=new ArrayList();
		// try {
		// list = new
		// TradingQueryDefaultWapper().selectBlacklistBySellerId(288484);
		// } catch (InterruptedException e) {
		// 
		// e.printStackTrace();
		// }
		// if (list.size()>0){
		// for (Map temp:list){
		// Logger.debug(temp);
		// Logger.debug("sellerid："+temp.get("iBuyerId"));
		// }
		// }
		try {
			// List<Map> list = new
			// TradingQueryDefaultWapper().selectOrderAndOrderInfo(m);
			// Logger.debug("数量:"+list.size());
			// Logger.debug(list);
			// List<Map> list2 = new
			// TradingQueryDefaultWapper().selectOrderAndOrderInfoAndidPic(m);
			// Logger.debug("数量:"+list2.size());
			// Logger.debug(list2);
			// List<Map> list3 = new
			// TradingQueryDefaultWapper().selectBuyedNumByProductid(m);
			// Logger.debug("数量:"+list3.size());
			// Logger.debug(list3);
			List<Map> list4 = new TradingQueryDefaultWapper().getBuyerOrderList(m);
			// Logger.debug(list4);
			Logger.debug("数量:" + list4.size());

		} catch (InterruptedException e) {

			e.printStackTrace();
		}

	}
}
